package zuoye_3_10;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

//6.ArrayList去重 
public class Zuoye_6 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list1 = new ArrayList<Integer>();
		ArrayList<Integer> list2 = new ArrayList<Integer>();
		System.out.println("输入第一个数组的元素，以空格分隔：");
        String[] input1 = sc.nextLine().split(" ");
        for (String num : input1) {
            list1.add(Integer.parseInt(num));
        }
        System.out.println("输入第二个数组的元素，以空格分隔：");
        String[] input2 = sc.nextLine().split(" ");
        for (String num : input2) {
            list2.add(Integer.parseInt(num));
        }
		System.out.println(Arrays.toString(change(list1,list2)));
	}

	private static Object[] change(ArrayList<Integer> list1, ArrayList<Integer> list2) {
		// TODO Auto-generated method stub
		HashMap<Integer, Integer> map = new HashMap<>();
		for(int num : list1) {
			map.put(num, 1);
		}
		for (int num : list2) {
            if (map.containsKey(num)) {
                map.remove(num);
            } else {
                map.put(num, 1);
            }
        }
		return map.keySet().toArray();
	}
}
